package org.freedoit.server.dao;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;

public class DAOFactory {
	private static ProjectDAO projectDAO;
	private static TaskDAO taskDAO;
	private static TaskTypeDAO taskTypeDAO;
	private static UserDAO userDAO;
	
	private static final String PMF_NAME = "doit";
	
	private static PersistenceManagerFactory pmfInstance;

	static PersistenceManagerFactory getPersistenceManagerFactory() {
		if (pmfInstance == null) {
			pmfInstance =JDOHelper.getPersistenceManagerFactory(PMF_NAME);
		}
		
		return pmfInstance;
	}

	public static ProjectDAO getProjectDAO() {
		if (projectDAO == null) {
			projectDAO = new ProjectDAO();
		}
		
		return projectDAO;
	}

	public static TaskDAO getTaskDAO() {
		if (taskDAO == null) {
			taskDAO = new TaskDAO();
		}
		
		return taskDAO;
	}

	public static TaskTypeDAO getTaskTypeDAO() {
		if (taskTypeDAO == null) {
			taskTypeDAO = new TaskTypeDAO();
		}
		
		return taskTypeDAO;
	}

	public static UserDAO getUserDAO() {
		if (userDAO == null) {
			userDAO = new UserDAO();
		}
		
		return userDAO;
	}
}
